#ifndef UTILS_H
#define UTILS_H

/**
Nectarine Utility Project is a software interface for the web system 'demovibes'
Copyright (C) 2010  Alexandre LAURENT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

website: http://code.google.com/p/nectarine-utility-project/
e-mail: lw.demoscene@gmail.com
**/

class QObject;
class QWidget;
class QIcon;
class QMenu;
class QAction;
class QString;
class QXmlStreamReader;

namespace Utils
{
    /**
    * Create a new entry in the QMenu*
    *
    * @param QWidget* the parent widget of the entry
    * @param QMenu* the parent menu of the entry
    * @param const QIcon& the icon of the entry
    * @param const QString& the name of the entry
    * @param const QString& the key sequence to set to the menu
    * @param const QString& the tip displayed when the cursor is on the entry
    * @param const QObject* the pointer of the receiver of the connection
    * @param const char* the function called when the signal is emitted
    * @param const bool false if the menu is disabled
    * @param const bool false if the menu is not checkable
    * @return QAction* return the entry newly created
    * @brief - Create the entry
    *             - Assign an icon
    * 		  - Assign a shortcut
    *	  	  - Assign a status description
    * 		  - Set if the menu is enabled or not
    * 		  - Connect the funtion
    */
    QAction* addActionInMenu(QWidget* pParent,
                             QMenu* pMenu,
                             const QIcon& icon,
                             const QString& entryName,
                             const QString& keySequence,
                             const QString& tipMessage,
                             const QObject* object,
                             const char* slotName,
                             const bool isEnabled=true,
                             const bool isCheckable=false);

    /**
     * Get the path to the flag file, depending of the flag ID
     * If the id is not recognised, the path to the nectaflag will be returned
     *
     * \param flagName the flag ID
     * \return the path to the flag file
     */
    const QString getFlagPathFromName(const QString& flagName);

    /**
     * Get the String contained in the XML node.
     *
     * \param xmlReader the XML file reader
     * \param data the string read
     * \return true if no problem
     */
    bool getXMLStringData(QXmlStreamReader& xmlReader, QString& data);

    /**
     * Parse the input string to know the value of the boolean
     *
     * \param booleanString string to parse
     * \param isOk return true if the parsing goes right
     * \return value found by parsing the string
     */
    bool booleanFactory(const QString& booleanString, bool* isOk=0);

    /**
     * Parse the input string to find a month in english
     *
     * \param stringDate the string to pass
     * \return the number of the month
     */
    unsigned int unlocalizedMonthFromString(const QString& stringDate);
}

#endif // UTILS_H
